<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<p style="border:1px solid black; width: 600px; height: 500px" id="talkMs"> </p>

<input id="message"/><button id="sendBtn" onclick="sendMsg()">发送</button>
</body>
<script>
  let ws = new WebSocket('ws://localhost:8080/myWs1');// 对应服务器的
  // let ws = new WebSocket('ws://localhost:8080/myWs1');// 对应服务器的
  ws.onopen = function () {
  };
  ws.onmessage = function (message) {
      document.getElementById("talkMs").innerHTML=message.data;
  }

  function sendMsg() {
      ws.send(document.getElementById("message").value)
      document.getElementById("message").value=""
  }
</script>
</html>
